//package org.ddd.pattern.event.springboot.rocketmq.publish.tt;
//
//
//import org.ddd.pattern.event.spring.external.rocketmq.core.EventEnvelope;
//import org.ddd.pattern.event.spring.external.rocketmq.core.ITopicGenerator;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.util.Objects;
//
//
//public class RocketMQEventDispatcherAdapter implements IEventDispatcherAdapter {
//
//    private final ITopicGenerator topicGenerator;
////    private final EventEnvelopeFormatterLoader envelopeFormatterLoader;
//    private final IEventDispatcher dispatcher;
//    private static final Logger log = LoggerFactory.getLogger(RocketMQEventDispatcherAdapter.class);
//    private  final StoredEventFactory storedEventFactory;
//
//    public RocketMQEventDispatcherAdapter(
//            ITopicGenerator topicGenerator,
//
//            IEventDispatcher dispatcher
//            , StoredEventFactory storedEventFactory) {
//        this.topicGenerator = topicGenerator;
////        this.envelopeFormatterLoader = envelopeFormatterLoader;
//        this.dispatcher = dispatcher;
//        this.storedEventFactory =storedEventFactory;
//    }
//
//
//    @Override
//    public EventDispatchResult dispatch(EventEnvelope eventEnvelope) {
//        Objects.requireNonNull(eventEnvelope);
//        StoredEvent storedEvent = storedEventFactory.createByEventEnvelope(eventEnvelope);
//
////    IEvent event = eventEnvelope.getEvent();
////    storedEvent.setLocation(String
////        .format("%s-%s", event.getTagName(), event.getId()));
////    storedEvent.setPersistenceId(event.getId());
////
////    final Class<? extends IEvent> aClass = event.getClass();
////
////    TopicModel topicModel = topicGenerator.generate(aClass);
////    IEventEnvelopeFormatter eventEnvelopeSerializer = envelopeFormatterLoader.load(eventEnvelope.getSerializer());
////    storedEvent.setPayload(eventEnvelopeSerializer.serializeToBytes(eventEnvelope));
////    storedEvent.setTopic(topicModel.getTopic());
////    storedEvent.setSubTopic(topicModel.getSubTopic());
////
////    storedEvent.setTagName(eventEnvelope.getEvent().getTagName());
////    storedEvent.setEventKey(eventEnvelope.getEventKey());
////    storedEvent.setEventType(eventEnvelope.getEvent().getClass().getName());
////    storedEvent.setSenderName(eventEnvelope.getSender().getName());
////    storedEvent.setSenderId(eventEnvelope.getSender().getId());
////    storedEvent.setSenderScope(eventEnvelope.getSender().getScope());
////    storedEvent.setStoredTime(eventEnvelope.getOccurredOn());
////    storedEvent.setVersion(eventEnvelope.getEvent().getVersion());
////    storedEvent.setSerializer(eventEnvelopeSerializer.serializer());
//
//        return dispatcher.dispatch(storedEvent);
//    }
//}
